import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    host: "0.0.0.0",
    cors: true,
    proxy: {
      // 使用 proxy 实例
      '/api': {
        target: 'https://uniqueker.top/connect.php', //那个链接咱们只要前面的部分
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/socket': {
        target: 'https://fe5zs1tu.lc-cn-n1-shared.com', // LeanCloud 服务器地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/socket/, '/1.1/classes/_Conversation'),
      },
    }
  },
});
